package com.zhuoan;

import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动程序
 *
 * @author ruoyi
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@MapperScan("com.zhuoan.project.*.*.mapper")
public class ZhoanApplication {

    private final static Logger logger = LoggerFactory.getLogger(ZhoanApplication.class);

    public static void main(String[] args) throws UnknownHostException {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        ConfigurableApplicationContext application = SpringApplication.run(ZhoanApplication.class, args);
        Environment env = application.getEnvironment();

        logger.info(" .----------------.  .----------------.  .----------------.  .----------------.  .-----------------.\n" +
            "| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |\n" +
            "| |  _________   | || |    _______   | || |     ____     | || |      __      | || | ____  _____  | |\n" +
            "| | |  _   _  |  | || |   /  ___  |  | || |   .'    `.   | || |     /  \\     | || ||_   \\|_   _| | |\n" +
            "| | |_/ | | \\_|  | || |  |  (__ \\_|  | || |  /  .--.  \\  | || |    / /\\ \\    | || |  |   \\ | |   | |\n" +
            "| |     | |      | || |   '.___`-.   | || |  | |    | |  | || |   / ____ \\   | || |  | |\\ \\| |   | |\n" +
            "| |    _| |_     | || |  |`\\____) |  | || |  \\  `--'  /  | || | _/ /    \\ \\_ | || | _| |_\\   |_  | |\n" +
            "| |   |_____|    | || |  |_______.'  | || |   `.____.'   | || ||____|  |____|| || ||_____|\\____| | |\n" +
            "| |              | || |              | || |              | || |              | || |              | |\n" +
            "| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |\n" +
            " '----------------'  '----------------'  '----------------'  '----------------'  '----------------' " +
            " \n\n 　　　　　　　　　　　　　　(♥◠‿◠)ﾉﾞ  卓安后台管理系统启动成功   ლ(´ڡ`ლ)ﾞ \n\n");

        String port = env.getProperty("server.port");
        String hostAddress = InetAddress.getLocalHost().getHostAddress();
        logger.info("\n----------------------------------------------------------\n\t" +
                "Application '{}' is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:{}\n\t" +
                "External: \thttp://{}:{}\n\t" +
                "Doc: \thttp://{}:{}/swagger-ui.html\n\t" +
                "Doc2: \thttp://{}:{}/doc.html\n" +
                "----------------------------------------------------------",
            env.getProperty("server.servlet.context-path"),
            port,
            hostAddress, port,
            hostAddress, port,
            hostAddress, port);
    }
}